package pers.wwz.study.jvm;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Random;

public class TestGC {
    /**
     * jvm参数:-XX:+UseSerialGC -XX:+PrintGCDetails -Xms16m -Xmx16m
     * jvm参数:-XX:+UseParNewGC -XX:+PrintGCDetails -Xms16m -Xmx16m
     * jvm参数:-XX:+UseParallelGC -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -Xms16m -Xmx16m
     * jvm参数:-XX:+UseConcMarkSweepGC -XX:+PrintGCDetails -Xms16m -Xmx16m
     * jvm参数:-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -Xmx256m
     * @param args
     * @throws Exception
     */
    public static void main(String[] args) throws Exception {
        List<Object> list = new ArrayList<Object>();
        while (true) {
            int sleep = new Random().nextInt(100);
            if (System.currentTimeMillis() % 2 == 0) {
                list.clear();
            } else {
                for (int i = 0; i < 10000; i++) {
                    Properties properties = new Properties();
                    properties.put("key_" + i, "value_" + System.currentTimeMillis() +
                            i);
                    list.add(properties);
                }
            }
            // System.out.println("list大小为：" + list.size());
            Thread.sleep(sleep);
        }
    }
}
